//
//  BQBaseViewController.swift
//  BQWB
//
//  Created by laibingqiang on 16/10/24.
//  Copyright © 2016年 laibingqiang. All rights reserved.
//

import UIKit

class BQBaseViewController: UIViewController {

    //判断是否登陆的属性
    //var isLogin:Bool = BQOAuthViewModel.shared.isLogin
    //未登录的界面
    var visitorV:BQBaseView?
    override func viewDidLoad() {
        super.viewDidLoad()

    
    }
    
    override func loadView() {
        
        if BQOAuthViewModel.shared.isLogin {
            view = tableView
        }
        else
        {
            let visitorV:BQBaseView = BQBaseView()
            
            view = visitorV
            
            self.visitorV = visitorV
            //点击按钮的闭包执行
            visitorV.colure = {[weak self] in
                
                self?.loginClink()
            }
            
            setupNav()
        }
        
    }
    //4个按钮监听方法
    @objc private func loginClink(){
        
        let vc:BQOAuthController = BQOAuthController()
        
        let nva:UINavigationController = UINavigationController(rootViewController: vc)
        
        self.present(nva, animated: true, completion: nil)
    }
    //未登录状态下，导航栏的设置
    private func setupNav(){
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(target: self, action: #selector(loginClink), imgName: nil, backImg: nil, title: "注册")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(target: self, action: #selector(loginClink), imgName: nil, backImg: nil, title: "登陆")
    }
    
    //懒加载
    lazy var tableView:UITableView = UITableView()

    
}
